/**
 * @param {number[]} nums
 * @return {number}
 */
var removeDuplicates = function(nums) {
  let target = 2
  for (let i = 2; i < nums.length; i++) {
    if (nums[target - 2] !== nums[i]) {
      nums[target] = nums[i]
      target++
    }
  }
  return target
};